<template>
  <div class="app-container">

    <template>
      <el-button type="primary" icon="el-icon-full-screen" @click="tableFullScreen" plain>全屏展示</el-button>
    </template>

    <!--数据表-->
    <el-table ref="tableContainer" v-loading="loading" :data="dashBoardList" stripe border highlight-current-row height="680">
      <!--空状态时的占位提示-->
      <template slot="empty">
        <el-empty>
          <el-button type="primary" @click="resetQuery">刷新试试</el-button>
        </el-empty>
      </template>
      <el-table-column width="50" align="center">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="order_no" width="160">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.order_no)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.order_no">
              {{ formatDisplayText(scope.row.order_no) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="区域" align="center" prop="region_name" width="160">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.region_name)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.region_name">
              {{ formatDisplayText(scope.row.region_name) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="钢种" align="center" prop="steel_grade" width="160">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.steel_grade)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.steel_grade">
              {{ formatDisplayText(scope.row.steel_grade) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="宽下限" align="center" prop="width_low" width="60"/>
      <el-table-column label="宽上限" align="center" prop="width_hi" width="60"/>
      <el-table-column label="厚下限" align="center" prop="thickness_low" width="60"/>
      <el-table-column label="厚上限" align="center" prop="thickness_hi" width="60"/>
      <el-table-column label="工艺要点" align="center" prop="process">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.process)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.process">
              {{ formatDisplayText(scope.row.process) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listDashBoard } from "@/api/showcase/showcase_1580/dashBoard1580";


export default {
  name: "DashBoard1580",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 工艺要点管理 表格数据
      dashBoardList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        currentUser: sessionStorage.getItem("currentUser"),
      },

    };
  },

  created() {
    this.getList();
  },


  methods: {
    /** 查询展示台 列表 */
    getList() {
      this.loading = true;
      listDashBoard(this.queryParams).then(response => {
        this.dashBoardList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 鼠标悬停显示格式化文字
    formatDisplayText(text) {
      if (text && text.length > 30) {
        return text.slice(0, 30) + '...';
      }
      return text;
    },
    formatContent(text) {
      return text ? text.replace(/\n/g, '<br>') : '';
    },

    //表格全屏
    tableFullScreen(){
      // this.$router.push({name:'dashBoard-fullscreen'}) //本页面打开
      window.open(this.$router.resolve({ name: 'dashBoard-fullscreen1580' }).href, '_blank'); //在新页面打开
    },

  }
};
</script>

<style scoped>
.cell-content { /*表格内文字防溢出 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

</style>
